https://leetcode.cn/problems/combination-sum/description/
class Solution {
public:
    vector<vector<int>> ret;
    vector<int> path;
    int _t;
    void dfs(vector<int>& nums,int pos,int pathsum)
    {
        if(pathsum==_t)
        {
            ret.push_back(path);
            return ;
        }
        if(pathsum>_t || pos==nums.size())
            return ;
        for(int i=0;i*nums[pos]+pathsum<=_t;i++)
        {
            if(i)  path.push_back(nums[pos]);
            dfs(nums,pos+1,pathsum+i*nums[pos]);
        }
        //恢复
        for(int i=1;i*nums[pos]+pathsum<=_t;i++)
        {
            path.pop_back();
        }
    }
    
    vector<vector<int>> combinationSum(vector<int>& nums, int target) {
        _t=target;
        dfs(nums,0,0);
        return ret;
    }
};